import { useEffect, useRef, useState } from "react";
import "./App.css";
import { AppScene } from "./Scene";

function App() {
  const canvasRef = useRef<HTMLCanvasElement>(null);
  const [scene, setScene] = useState<AppScene>();
  const initRef = useRef(false);

  useEffect(() => {
    if (initRef.current) return;
    initRef.current = true;

    setScene(new AppScene(canvasRef.current!));
  }, []);

  console.log("scene", scene);

  return (
    <>
      <canvas className="scene" ref={canvasRef}></canvas>
    </>
  );
}

export default App;
